package tech.aistar.corejava.day09.strings;

/**
 * @author success
 * @version 1.0
 * @description:本类用来演示:
 * @date 2019/7/25 0025
 */
public class StringPlusDemo {
    public static void main(String[] args) {
        //System.out.println(System.currentTimeMillis());
        testAppend();

        testStringPlus();
    }

    public static void testAppend(){
        long date = System.currentTimeMillis();

        StringBuilder str = new StringBuilder("");
        for (int i = 0; i < 100000; i++) {
            //str += i;//str = str + i;
            str.append(i);
        }
        System.out.println(System.currentTimeMillis() - date);
    }

    public static void testStringPlus(){
        //获取当前系统的毫秒数
        //距离1970年的1月1日.
        long date = System.currentTimeMillis();

        //程序
        String str = "";
        for (int i = 0; i < 100000; i++) {
            str += i;//str = str + i;
        }
        System.out.println(System.currentTimeMillis() - date);
    }
}
